This page last changed on Jun 02, 2006 by stephen fenech.

Developers can use the QuickConfigurationBuilder to programmatically build a Mule Manager instance.

This can be especially useful when configuring a Mule Instance from script or for test cases. You can configure a server with only a few lines of code, for example to configure a server with a single component -

QuickConfigurationBuilder builder = new QuickConfigurationBuilder();
builder.createStartedManager(true, "tcp://localhost:60504");

UMOEndpoint inboundEndpoint = new MuleEndpoint("axis:http://localhost:81/services");
builder.registerComponent(EchoComponent.class.getName(), "echoComponent", inboundEndpoint);

This creates a new Mule Instance with a server admin url of 'tcp://localhost:60504' (if you don't want the Mule Admin Agent to start, set this to ""). It also creates a Mule Component called 'echoComponent' that is an Axis web service that will receive requests on 'http://localhost:81/services/echoComponent'.

The following example creates an asynchronous Mule Instance without an Admin Agent with a single component that receives events via tcp and writes them out to file.

QuickConfigurationBuilder builder = new QuickConfigurationBuilder();
builder.createStartedManager(false, "");

UMOEndpoint inboundEndpoint = new MuleEndpoint("tcp://localhost:5555");
UMOEndpoint outboundEndpoint = new MuleEndpoint("file:///tmp/events");

builder.registerComponent(AnotherComponent.class.getName(), "aComponent",
                                           inboundEndpoint, outboundEndpoint);

The next example demonstrates adding additional configuration to the manager. In this case adding a jms connector.

QuickConfigurationBuilder builder = new QuickConfigurationBuilder();
UMOManager manager = builder.createStartedManager(false, "");

//Only the jms connector cannot be created automatically,
//so we must create one, we'll use ActiveMQ
JmsConnector connector = new JmsConnector();
connector.setName("jmsConnector");
connector.setJndiInitialFactory("org.codehaus.activemq.jndi.ActiveMQInitialContextFactory");
connector.setConnectionFactoryJndiName("ConnectionFactory");
connector.setSpecification(JmsConnector.JMS_SPECIFICATION_11);

//Register the connector with the server
manager.registerConnector(connector);

UMOEndpoint inboundEndpoint = new MuleEndpoint("tcp://localhost:5555");
UMOEndpoint outboundEndpoint = new MuleEndpoint("jms://topic:jms.topic");

builder.registerComponent(AnotherComponent.class.getName(), "aComponent",
                                           inboundEndpoint, outboundEndpoint);
Document generated by Confluence on Nov 27, 2006 10:27